

cd "$data"
use "data1.dta", clear


		* APPENDIX 2
		
		
		*FIGURE 2.1. Distribution of Perceived shift among Labour Identifiers 
		
	hist perceivedshiftw6w7_L if Labouridentification6_==1, percent discrete xtitle("") xline(0, lpattern(dash) lcolor(black)) color(cranberry%30) title("perceived shift among Labour identifiers") xtitle("perceived shift of the Labour Party between wave 6 and 7")
graph save "${figures}/A_Figure2_1.gph",replace 

		*FIGURE 2.2. Distribution of Perceived shift among Independents

	hist perceivedshiftw6w7_L if Labouridentification6_==0, percent discrete xtitle("") xline(0, lpattern(dash) lcolor(black)) color(gs6%50) title("Perceived shift among independents") xtitle("perceived shift of the Labour Party between wave 6 and 7")
graph save "${figures}/A_Figure2_2.gph",replace 

		*FIGURE 2.3. Distribution of Perceived shift among other Identifiers

	gen others = . 
	replace others = 1 if pid6==1 | pid6==3 | pid6==4 | pid6==5 

	hist perceivedshiftw6w7_L if others==1, percent discrete xtitle("") xline(0, lpattern(dash) lcolor(black)) color(gs6%70) title("Perceived shift among other identifiers") xtitle("perceived shift of the Labour Party between wave 6 and 7")
	
graph save "${figures}/A_Figure2_2.gph",replace 


		* TABLE 2.1. Who perceived the shift?
		
		*without controls 
	eststo A2_M1: regress perceivedshiftw6w7_L i.pid6, robust 
	margins, at(pid6=(0 1 2 3 4 5))
	marginsplot, plotopts(color(cranberry%50) msymbol(circle)) recast(scatter) recastci(rspike) level(95) xlabel(, angle(vertical) labsize(2)) ciopts(color(cranberry%50)) title("") ytitle("wave 6 - wave 7") ytitle(, size(vsmall)) xtitle(`""', size(small)) note(`""', size(vsmall))
	graph save "${figures}/whoperceived67.gph",replace 
	
	eststo A2_M2: regress perceivedshiftw6w12_L i.pid6, robust
	margins, at(pid6=(0 1 2 3 4 5))
	marginsplot, plotopts(color(cranberry%50) msymbol(circle)) recast(scatter) recastci(rspike) level(95) xlabel(, angle(vertical) labsize(2)) ciopts(color(cranberry%50)) title("")  ytitle("wave 6 - wave 12") ytitle(, size(vsmall)) xtitle(`""', size(small)) note(`""', size(vsmall))
	graph save "${figures}/whoperceived612.gph",replace 

	eststo A2_M3: regress perceivedshiftw6w18_L i.pid6, robust
	margins, at(pid6=(0 1 2 3 4 5))
	marginsplot, plotopts(color(cranberry%50) msymbol(circle)) recast(scatter) recastci(rspike) level(95) xlabel(, angle(vertical) labsize(2)) ciopts(color(cranberry%50)) title("")  ytitle("wave 6 - wave 18") ytitle(, size(vsmall)) xtitle(`""', size(small)) note(`""', size(vsmall))
	graph save "${figures}/whoperceived618.gph",replace 
	
	
		*with controls 
	eststo A2_M1_: regress perceivedshiftw6w7_L i.pid6 leftright6 attention6 education6 sex age6, robust
	margins, at(pid6=(0 1 2 3 4 5))
	marginsplot, plotopts(color(cranberry%50) msymbol(circle)) recast(scatter) recastci(rspike) level(95) xlabel(, angle(vertical) labsize(2)) ciopts(color(cranberry%50)) title("") ytitle("wave 6 - wave 7") ytitle(, size(vsmall)) xtitle(`""', size(small)) note(`""', size(vsmall))

	eststo A2_M2_: regress perceivedshiftw6w12_L i.pid6 leftright6 attention6 education6 sex age6, robust
	margins, at(pid6=(0 1 2 3 4 5))
	marginsplot, plotopts(color(cranberry%50) msymbol(circle)) recast(scatter) recastci(rspike) level(95) xlabel(, angle(vertical) labsize(2)) ciopts(color(cranberry%50)) title("")  ytitle("wave 6 - wave 12") ytitle(, size(vsmall)) xtitle(`""', size(small)) note(`""', size(vsmall))

	eststo A2_M3_: regress perceivedshiftw6w18_L i.pid6 leftright6 attention6 education6 sex age6, robust
	margins, at(pid6=(0 1 2 3 4 5))
	marginsplot, plotopts(color(cranberry%50) msymbol(circle)) recast(scatter) recastci(rspike) level(95) xlabel(, angle(vertical) labsize(2)) ciopts(color(cranberry%50)) title("")  ytitle("wave 6 - wave 18") ytitle(, size(vsmall)) xtitle(`""', size(small)) note(`""', size(vsmall))
	
	
	
	esttab A2_M1 A2_M1_ A2_M2 A2_M2_ A2_M3 A2_M3_ using "${tables}/whoperceived.tex" , b(3) se(3) nogap replace  // if you use latex
	esttab A2_M1 A2_M1_ A2_M2 A2_M2_ A2_M3 A2_M3_ using "${tables}/whoperceived.rtf" , b(3) se(3) nogap  replace // if you use word

	
	* FIGURE 2.4. Who perceived the leftward shift of the Labour Party 
	cd "$figures"
	graph combine whoperceived618.gph whoperceived612.gph whoperceived67.gph, ycommon cols(1) xsize(10) ysize(18) // this is based on the models without controls. 
	
	
